package models

import (
	"github.com/astaxie/beego/orm"
	beego "github.com/beego/beego/v2/server/web"
	_ "github.com/go-sql-driver/mysql"
)

func init() {
	username, _ := beego.AppConfig.String("username")
	password, _ := beego.AppConfig.String("password")
	dbname, _ := beego.AppConfig.String("dbname")
	host, _ := beego.AppConfig.String("host")
	port, _ := beego.AppConfig.String("port")

	dsn := username + ":" + password + "@tcp(" + host + ":" + port + ")/" + dbname + "?charset=utf8"

	orm.RegisterDriver("mysql", orm.DRMySQL)

	orm.RegisterDataBase("default", "mysql", dsn)

	orm.RegisterModel(new(Info))
}
